//
//  MCMallStatisticsSectionFooterView.swift
//  StoreManage
//
//  Created by MC on 2018/8/30.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit

class MCMallStatisticsSectionFooterView: UIView {
    
    var model = MCOrderListFatherModel() {
        didSet {
            totalMoneyAndTimeView.rightLabel.text = model.createTime.MCString_prefix(index: 16)
            
            var freightStr = ""
            
            if model.freight.intValue == 0 {
                freightStr = " (免运费)"
            } else {
                freightStr = " (含运费\(MCString_judgemantDecimalsIsZero(figure: model.freight.intValue)))"
            }
            
            totalMoneyAndTimeView.leftLabel.text = "共" + model.totalQuantity.stringValue + "件,合计:"
                + MCString_judgemantDecimalsIsZero(figure: model.totalFee.intValue) + freightStr
            
            salerView.rightLabel.text = model.salesman
            commissionView.rightLabel.text = MCString_judgemantDecimalsIsZero(figure: model.totalCommision.intValue)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor.MCGray_light
        setUpSubViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUpSubViews() {
        
        
        self.addSubview(bgView)
        bgView.snp.remakeConstraints { (make) ->Void in
            make.edges.equalTo(self).inset(UIEdgeInsetsMake(0, 0, 5, 0))
        }
        
        bgView.addSubview(totalMoneyAndTimeView)
        totalMoneyAndTimeView.snp.updateConstraints { (make) -> Void in
            make.top.equalTo(bgView).offset(10)
            make.height.equalTo(15)
            make.left.equalTo(bgView).offset(15)
            make.right.equalTo(bgView).offset(-15)
        }
        
        
        bgView.addSubview(salerView)
        salerView.snp.remakeConstraints { (make) ->Void in
            make.left.right.equalTo(totalMoneyAndTimeView)
            make.height.equalTo(15)
            make.top.equalTo(totalMoneyAndTimeView.snp.bottom).offset(10)
        }
        
        bgView.addSubview(commissionView)
        commissionView.snp.remakeConstraints { (make) ->Void in
            make.left.right.equalTo(salerView)
            make.height.equalTo(15)
            make.top.equalTo(salerView.snp.bottom).offset(10)
        }
    }
    
    lazy var bgView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.white
        return view
    }()
    
    
    
    lazy var totalMoneyAndTimeView: MCShowBarView = {
        let view = MCShowBarView()
        view.rightLabel.font = MCFont(12)
        view.rightLabel.textColor = UIColor.MCGray_middle
        return view
    }()
    
    
    lazy var salerView: MCShowBarView = {
        let view = MCShowBarView()
        view.leftLabel.text = "销售人"
        view.lineView.isHidden = true
        return view
    }()

    
    lazy var commissionView: MCShowBarView = {
        let view = MCShowBarView()
        view.leftLabel.text = "总佣金"
        view.lineView.isHidden = true
        return view
    }()
}
